﻿using GraphProcessor;
using IQIGame.Onigao.Logic;
using UnityEngine;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.Prefab, typeof(LevelServiceGraph))]
    public class LevelServiceExecutionNode_Prefab : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.Prefab;

        public override string name => LevelEditorConst.Prefab;
        [LevelServicePrefabDropdown(2)]
        public string prefab;

        protected override LevelServiceCustomConfig CreateConfig()
        {
            var rConfig = new LevelServiceExecutionCustom_Prefab()
            {
                key = this.prefab,
            };
            return rConfig;
        }

        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            if (newConfig.customConfig is LevelServiceExecutionCustom_Prefab rPrefabConfig)
            {
                this.prefab = rPrefabConfig.key;
            }
        }
    }
}